﻿using GalaSoft.MvvmLight.Messaging;
using Microsoft.Practices.Unity;
using Reactor.Client.Services;
using Reactor.Client.ViewModel;

namespace Reactor.Client
{
    public class Bootstrapper
    {
        public UnityContainer Container { get; set; }

        public void Run()
        {
            Container = new UnityContainer();

            Container.RegisterInstance<IMessenger>(Messenger.Default);
            
            // Register an IReactorServiceAgent instance
            Container.RegisterInstance<IReactorServiceAgent>(new DesignerServiceAgent());
            //Container.RegisterInstance<IReactorServiceAgent>(new ReactorServiceAgent());

            Container.RegisterType<IViewModelLocator, ViewModelLocator>();
            Container.RegisterInstance<IDialogService>(new DialogService(Container.Resolve<IViewModelLocator>()));

            // Singleton ViewModels
            Container.RegisterType<MainViewModel>(new ContainerControlledLifetimeManager());
            Container.RegisterType<HomeViewModel>(new ContainerControlledLifetimeManager());
        }
    }
}
